.class public Lnet/oauth/client/URLConnectionResponse;
.super Lnet/oauth/http/HttpResponseMessage;
.source "URLConnectionResponse.java"


# instance fields
.field private final connection:Ljava/net/URLConnection;

.field private final requestEncoding:Ljava/lang/String;

.field private final requestExcerpt:[B

.field private final requestHeaders:Ljava/lang/String;


# direct methods
.method public constructor <init>(Lnet/oauth/http/HttpMessage;Ljava/lang/String;[BLjava/net/URLConnection;)V
    .locals 2
    .parameter "request"
    .parameter "requestHeaders"
    .parameter "requestExcerpt"
    .parameter "connection"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 45
    iget-object v0, p1, Lnet/oauth/http/HttpMessage;->method:Ljava/lang/String;

    iget-object v1, p1, Lnet/oauth/http/HttpMessage;->url:Ljava/net/URL;

    invoke-direct {p0, v0, v1}, Lnet/oauth/http/HttpResponseMessage;-><init>(Ljava/lang/String;Ljava/net/URL;)V

    .line 46
    iput-object p2, p0, Lnet/oauth/client/URLConnectionResponse;->requestHeaders:Ljava/lang/String;

    .line 47
    iput-object p3, p0, Lnet/oauth/client/URLConnectionResponse;->requestExcerpt:[B

    .line 48
    invoke-virtual {p1}, Lnet/oauth/http/HttpMessage;->getContentCharset()Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lnet/oauth/client/URLConnectionResponse;->requestEncoding:Ljava/lang/String;

    .line 49
    iput-object p4, p0, Lnet/oauth/client/URLConnectionResponse;->connection:Ljava/net/URLConnection;

    .line 50
    iget-object v0, p0, Lnet/oauth/client/URLConnectionResponse;->headers:Ljava/util/List;

    invoke-direct {p0}, Lnet/oauth/client/URLConnectionResponse;->getHeaders()Ljava/util/List;

    move-result-object v1

    invoke-interface {v0, v1}, Ljava/util/List;->addAll(Ljava/util/Collection;)Z

    .line 51
    return-void
.end method

.method private getHeaders()Ljava/util/List;
    .locals 8
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/List",
            "<",
            "Ljava/util/Map$Entry",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;>;"
        }
    .end annotation

    .prologue
    .line 96
    new-instance v1, Ljava/util/ArrayList;

    invoke-direct {v1}, Ljava/util/ArrayList;-><init>()V

    .line 97
    .local v1, headers:Ljava/util/List;,"Ljava/util/List<Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;>;"
    const/4 v0, 0x0

    .line 99
    .local v0, foundContentType:Z
    const/4 v2, 0x0

    .local v2, i:I
    :goto_0
    iget-object v5, p0, Lnet/oauth/client/URLConnectionResponse;->connection:Ljava/net/URLConnection;

    invoke-virtual {p0, v5, v2}, Lnet/oauth/client/URLConnectionResponse;->getHeaderField(Ljava/net/URLConnection;I)Ljava/lang/String;

    move-result-object v4

    .local v4, value:Ljava/lang/String;
    if-eqz v4, :cond_1

    .line 100
    iget-object v5, p0, Lnet/oauth/client/URLConnectionResponse;->connection:Ljava/net/URLConnection;

    invoke-virtual {p0, v5, v2}, Lnet/oauth/client/URLConnectionResponse;->getHeaderFieldKey(Ljava/net/URLConnection;I)Ljava/lang/String;

    move-result-object v3

    .line 101
    .local v3, name:Ljava/lang/String;
    if-eqz v3, :cond_0

    .line 102
    new-instance v5, Lnet/oauth/OAuth$Parameter;

    invoke-direct {v5, v3, v4}, Lnet/oauth/OAuth$Parameter;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    invoke-interface {v1, v5}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 103
    const-string v5, "Content-Type"

    invoke-virtual {v5, v3}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_0

    .line 104
    const/4 v0, 0x1

    .line 99
    :cond_0
    add-int/lit8 v2, v2, 0x1

    goto :goto_0

    .line 108
    .end local v3           #name:Ljava/lang/String;
    :cond_1
    if-nez v0, :cond_2

    .line 109
    new-instance v5, Lnet/oauth/OAuth$Parameter;

    const-string v6, "Content-Type"

    iget-object v7, p0, Lnet/oauth/client/URLConnectionResponse;->connection:Ljava/net/URLConnection;

    invoke-virtual {v7}, Ljava/net/URLConnection;->getContentType()Ljava/lang/String;

    move-result-object v7

    invoke-direct {v5, v6, v7}, Lnet/oauth/OAuth$Parameter;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    invoke-interface {v1, v5}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 112
    :cond_2
    return-object v1
.end method


# virtual methods
.method public dump(Ljava/util/Map;)V
    .locals 11
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/Object;",
            ">;)V"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 117
    .local p1, into:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;"
    invoke-super {p0, p1}, Lnet/oauth/http/HttpResponseMessage;->dump(Ljava/util/Map;)V

    .line 119
    new-instance v5, Ljava/lang/StringBuilder;

    iget-object v8, p0, Lnet/oauth/client/URLConnectionResponse;->requestHeaders:Ljava/lang/String;

    invoke-direct {v5, v8}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 120
    .local v5, request:Ljava/lang/StringBuilder;
    const-string v8, "\r\n"

    invoke-virtual {v5, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 121
    iget-object v8, p0, Lnet/oauth/client/URLConnectionResponse;->requestExcerpt:[B

    if-eqz v8, :cond_0

    .line 122
    new-instance v8, Ljava/lang/String;

    iget-object v9, p0, Lnet/oauth/client/URLConnectionResponse;->requestExcerpt:[B

    iget-object v10, p0, Lnet/oauth/client/URLConnectionResponse;->requestEncoding:Ljava/lang/String;

    invoke-direct {v8, v9, v10}, Ljava/lang/String;-><init>([BLjava/lang/String;)V

    invoke-virtual {v5, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 124
    :cond_0
    const-string v8, "HTTP request"

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-interface {p1, v8, v9}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 127
    iget-object v8, p0, Lnet/oauth/client/URLConnectionResponse;->connection:Ljava/net/URLConnection;

    instance-of v8, v8, Ljava/net/HttpURLConnection;

    if-eqz v8, :cond_4

    iget-object v8, p0, Lnet/oauth/client/URLConnectionResponse;->connection:Ljava/net/URLConnection;

    check-cast v8, Ljava/net/HttpURLConnection;

    move-object v1, v8

    .line 129
    .local v1, http:Ljava/net/HttpURLConnection;
    :goto_0
    new-instance v6, Ljava/lang/StringBuilder;

    invoke-direct {v6}, Ljava/lang/StringBuilder;-><init>()V

    .line 131
    .local v6, response:Ljava/lang/StringBuilder;
    const/4 v2, 0x0

    .local v2, i:I
    :goto_1
    iget-object v8, p0, Lnet/oauth/client/URLConnectionResponse;->connection:Ljava/net/URLConnection;

    invoke-virtual {p0, v8, v2}, Lnet/oauth/client/URLConnectionResponse;->getHeaderField(Ljava/net/URLConnection;I)Ljava/lang/String;

    move-result-object v7

    .local v7, value:Ljava/lang/String;
    if-eqz v7, :cond_5

    .line 132
    iget-object v8, p0, Lnet/oauth/client/URLConnectionResponse;->connection:Ljava/net/URLConnection;

    invoke-virtual {p0, v8, v2}, Lnet/oauth/client/URLConnectionResponse;->getHeaderFieldKey(Ljava/net/URLConnection;I)Ljava/lang/String;

    move-result-object v4

    .line 133
    .local v4, name:Ljava/lang/String;
    if-nez v2, :cond_2

    if-eqz v4, :cond_2

    if-eqz v1, :cond_2

    .line 134
    new-instance v8, Ljava/lang/StringBuilder;

    invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

    const-string v9, "HTTP "

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {p0}, Lnet/oauth/client/URLConnectionResponse;->getStatusCode()I

    move-result v9

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    .line 135
    .local v0, firstLine:Ljava/lang/String;
    invoke-virtual {v1}, Ljava/net/HttpURLConnection;->getResponseMessage()Ljava/lang/String;

    move-result-object v3

    .line 136
    .local v3, message:Ljava/lang/String;
    if-eqz v3, :cond_1

    .line 137
    new-instance v8, Ljava/lang/StringBuilder;

    invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v8, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    const-string v9, " "

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    .line 139
    :cond_1
    invoke-virtual {v6, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    const-string v9, "\r\n"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 141
    .end local v0           #firstLine:Ljava/lang/String;
    .end local v3           #message:Ljava/lang/String;
    :cond_2
    if-eqz v4, :cond_3

    .line 142
    invoke-virtual {v6, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    const-string v9, ": "

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 143
    invoke-virtual {v4}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v4

    .line 145
    :cond_3
    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    const-string v9, "\r\n"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 131
    add-int/lit8 v2, v2, 0x1

    goto :goto_1

    .line 127
    .end local v1           #http:Ljava/net/HttpURLConnection;
    .end local v2           #i:I
    .end local v4           #name:Ljava/lang/String;
    .end local v6           #response:Ljava/lang/StringBuilder;
    .end local v7           #value:Ljava/lang/String;
    :cond_4
    const/4 v1, 0x0

    goto :goto_0

    .line 147
    .restart local v1       #http:Ljava/net/HttpURLConnection;
    .restart local v2       #i:I
    .restart local v6       #response:Ljava/lang/StringBuilder;
    .restart local v7       #value:Ljava/lang/String;
    :cond_5
    const-string v8, "\r\n"

    invoke-virtual {v6, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 148
    iget-object v8, p0, Lnet/oauth/client/URLConnectionResponse;->body:Ljava/io/InputStream;

    if-eqz v8, :cond_6

    .line 149
    new-instance v9, Ljava/lang/String;

    iget-object v8, p0, Lnet/oauth/client/URLConnectionResponse;->body:Ljava/io/InputStream;

    check-cast v8, Lnet/oauth/client/ExcerptInputStream;

    invoke-virtual {v8}, Lnet/oauth/client/ExcerptInputStream;->getExcerpt()[B

    move-result-object v8

    invoke-virtual {p0}, Lnet/oauth/client/URLConnectionResponse;->getContentCharset()Ljava/lang/String;

    move-result-object v10

    invoke-direct {v9, v8, v10}, Ljava/lang/String;-><init>([BLjava/lang/String;)V

    invoke-virtual {v6, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 152
    :cond_6
    const-string v8, "HTTP response"

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-interface {p1, v8, v9}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 154
    return-void
.end method

.method protected getHeaderField(Ljava/net/URLConnection;I)Ljava/lang/String;
    .locals 2
    .parameter "connection"
    .parameter "index"

    .prologue
    .line 77
    :try_start_0
    invoke-virtual {p1, p2}, Ljava/net/URLConnection;->getHeaderField(I)Ljava/lang/String;
    :try_end_0
    .catch Ljava/util/NoSuchElementException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v1

    .line 81
    :goto_0
    return-object v1

    .line 78
    :catch_0
    move-exception v0

    .line 81
    .local v0, e:Ljava/util/NoSuchElementException;
    const/4 v1, 0x0

    goto :goto_0
.end method

.method protected getHeaderFieldKey(Ljava/net/URLConnection;I)Ljava/lang/String;
    .locals 2
    .parameter "connection"
    .parameter "index"

    .prologue
    .line 87
    :try_start_0
    invoke-virtual {p1, p2}, Ljava/net/URLConnection;->getHeaderFieldKey(I)Ljava/lang/String;
    :try_end_0
    .catch Ljava/util/NoSuchElementException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v1

    .line 91
    :goto_0
    return-object v1

    .line 88
    :catch_0
    move-exception v0

    .line 91
    .local v0, e:Ljava/util/NoSuchElementException;
    const/4 v1, 0x0

    goto :goto_0
.end method

.method public getStatusCode()I
    .locals 1
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 60
    iget-object v0, p0, Lnet/oauth/client/URLConnectionResponse;->connection:Ljava/net/URLConnection;

    instance-of v0, v0, Ljava/net/HttpURLConnection;

    if-eqz v0, :cond_0

    .line 61
    iget-object v0, p0, Lnet/oauth/client/URLConnectionResponse;->connection:Ljava/net/URLConnection;

    check-cast v0, Ljava/net/HttpURLConnection;

    invoke-virtual {v0}, Ljava/net/HttpURLConnection;->getResponseCode()I

    move-result v0

    .line 63
    :goto_0
    return v0

    :cond_0
    const/16 v0, 0xc8

    goto :goto_0
.end method

.method public openBody()Ljava/io/InputStream;
    .locals 1

    .prologue
    .line 69
    :try_start_0
    iget-object v0, p0, Lnet/oauth/client/URLConnectionResponse;->connection:Ljava/net/URLConnection;

    invoke-virtual {v0}, Ljava/net/URLConnection;->getInputStream()Ljava/io/InputStream;
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v0

    .line 72
    :goto_0
    return-object v0

    .line 70
    :catch_0
    move-exception v0

    .line 72
    const/4 v0, 0x0

    goto :goto_0
.end method
